home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #6 / Amiga Plus CD - 1996 - No. 06.iso / pd / programmierung / proasm / routines / graphicslib.r < prev    next >
Text File  |  1980-01-25  |  3KB  |  130 lines

  1.  
  2. ;---;  graphicslib.r  ;--------------------------------------------------------
  3. *
  4. *    ****    GRAPHICS LIBRARY OPEN AND CLOSE    ****
  5. *
  6. *    Author        Stefan Walter
  7. *    Version        1.00
  8. *    Last Revision    31.05.92
  9. *    Identifier    glb_defined
  10. *       Prefix        glb_    (graphics library)
  11. *                 ¯        ¯ ¯
  12. *    Functions    OpenGraphicsLib, GetGraphicsBase, CloseGraphicsLib
  13. *
  14. ;------------------------------------------------------------------------------
  15.  
  16. ;------------------
  17.     ifnd    glb_defined
  18. glb_defined    =0
  19.  
  20. ;------------------
  21. glb_oldbase    equ    __base
  22.     base    glb_base
  23. glb_base:
  24.  
  25. ;------------------
  26.  
  27. ;------------------------------------------------------------------------------
  28. *
  29. * OpenGraphicsLib    Open graphics.library once and use a nesting counter.
  30. *
  31. * RESULT:    d0    gfxbase
  32. *        a6    also
  33. *        ccr    on d0
  34. *
  35. ;------------------------------------------------------------------------------
  36.  
  37. ;------------------
  38. OpenGraphicsLib:
  39.  
  40. ;------------------
  41. ; open only if glb_nestcnt=0
  42. ;
  43. \open:
  44.     movem.l    d1-a5,-(sp)
  45.     lea    glb_base(pc),a4
  46.     move.l    glb_nestcnt(pc),d0
  47.     bne.s    \isopen
  48.     move.l    4.w,a6
  49.     lea    glb_name(pc),a1
  50.     jsr    -408(a6)        ;OldOpenLibrary()
  51.     move.l    d0,glb_gfxbase(a4)
  52. \isopen:
  53.     addq.l    #1,glb_nestcnt(a4)
  54.     move.l    glb_gfxbase(pc),d0
  55.     move.l    d0,a6
  56.     movem.l    (sp)+,d1-a5
  57.     rts
  58.  
  59. ;------------------
  60.  
  61. ;------------------------------------------------------------------------------
  62. *
  63. * GetGraphicsBase    Get gfxbase in a6.
  64. *
  65. * RESULT:    a6    gfxbase
  66. *
  67. ;------------------------------------------------------------------------------
  68.  
  69. ;------------------
  70. GetGraphicsBase:
  71.  
  72. ;------------------
  73. ; gfxbase => a6
  74. ;
  75. \getbase:
  76.     move.l    glb_gfxbase(pc),a6
  77.     rts
  78.  
  79. ;------------------
  80.  
  81. ;------------------------------------------------------------------------------
  82. *
  83. * CloseGraphicsLib    Close graphics.library if glb_nestcnt gets zero.
  84. *
  85. ;------------------------------------------------------------------------------
  86.  
  87. ;------------------
  88. CloseGraphicsLib:
  89.  
  90. ;------------------
  91. ; decrease dlb_nestcnt and close library if finished
  92. ;
  93. \close:
  94.     movem.l    d0-a6,-(sp)
  95.     lea    glb_nestcnt(pc),a4
  96.     subq.l    #1,(a4)
  97.     bhi.s    \end
  98.     move.l    glb_gfxbase(pc),a1
  99.     move.l    a1,d0
  100.     beq.s    \end
  101.     move.l    4.w,a6
  102.     jsr    -414(a6)        ;CloseLibrary()
  103. \end:
  104.     movem.l    (sp)+,d0-a6
  105.     rts
  106.  
  107. ;------------------
  108.  
  109. ;--------------------------------------------------------------------
  110.  
  111. ;------------------
  112. ; data for library handling
  113. ;
  114. glb_name:    dc.b    "graphics.library",0,0
  115. glb_gfxbase:    dc.l    0
  116. glb_nestcnt:    dc.l    0
  117.  
  118. ;------------------
  119.  
  120. ;--------------------------------------------------------------------
  121.  
  122. ;------------------
  123.     base    glb_oldbase
  124.  
  125. ;------------------
  126.     endif
  127.  
  128.  end
  129.  
  130.